package gipf.trunk;
/**
 * @author eric
 *a positions holds it's index in the int[] array of pieces
 *it also holds the GUI coordinate
 *also the position on the board (e.g. 5|5)
 *and finally also holds the coordiante where this position is stored in the
 *position[][] board (which is 17*17) and used to travel trough the board with a vector
 */
public class position {
	private int x;
	private int y;
	private int index;
	private int[] boardIndex;
	private int[] GUIcoordinate;
	
	/**
	 * initialize an empty position, identified by the index 61 (which does not exist)
	 */
	public position(){
		x = 0;
		y = 0;
		index = 61;
	}
	
	/**
	 * @param x "letter" position of the board (A B C D E F G H I) represented by numbers
	 * @param y number value of the position
	 */
	public position(int x, int y){
		this.x = x;
		this.y = y;
		index = staticBoard.translatePosition(this);
	}
	
	/**
	 * @param a
	 * @param b
	 * 
	 * if not initialized with a position, it can be set here
	 */
	public void setBoardIndex(int a, int b){
		boardIndex = new int[2];
		boardIndex[0] = a;
		boardIndex[1] = b;
	}
	
	/**
	 * @return the location of the position in the board[][], a 17*17 matrix
	 */
	public int[] getBoardIndex(){
		return boardIndex;
	}
	
	/**
	 * @return the index of a position (0 - 60)
	 */
	public int getIndex(){
		return index;
	}
	
	/**
	 * @return the location of the position in means of (e.g. 5|5)
	 */
	public int[] coordinate(){
		int[] coor = new int[2];
		coor[0] = x; 
		coor[1] = y;
		
		return coor;
	}
	
	/**
	 * @return the GUI coordinate, where the position is drawn
	 */
	public int[] getGUIcoordinate() {
		return GUIcoordinate;
	}

	/**
	 * @param x
	 * @param y
	 * 
	 * set the gui coordinate of the position
	 */
	public void setGUIcoordinate(int x, int y) {
		GUIcoordinate = new int[2];
		GUIcoordinate[0] = x;
		GUIcoordinate[1] = y;
	}

	public String toString(){
		return ("[" + x + "|"+ y + "]");
	}
	

}
